<?php

require_once('../domain/Sportart.php');

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SaisonSelection
 *
 * @author riemerb
 */
class SportartSelection {
    private
        $sportarten, //object
        $selected;   //int

    public function __construct($sportarten = null, $withEmtryEntry = false) 
    {
        $i = 0;

        if($withEmtryEntry) {
            $this->sportarten = array();
            $this->sportarten[$i] = new Sportart(0, "     ");
            $this->selected = 0;
        } else {
            $this->selected = 1;
        }
                
        $i++;
        foreach ( $sportarten as $sportart){
            $this->sportarten[$i] = $sportart;
            $i++;
        }        
    }
   
    public function setSelectedIndex($selected){
        if ((count($this->sportarten)) >= $selected && 0 <= $selected){
            $this->selected = $selected;        
        } else {
            $this->selected = 0;
        }
    }

/*
    public function setSelectedSaison($selected){
        $length = count($this->sportarten)-1;
        for ($i = 0; $i <= $length; $i++) {
            $saison = $this->sportarten[$i];
            if ((strcmp($saison->getBeginn(), $selected->getBeginn()) == 0)
                && (strcmp($saison->getEnde(), $selected->getEnde()) == 0)
            ) {
                $this->sportarten = $i;
                break;
            }
        }
    }
*/
    public function getSelectedIndex(){
        return $this->selected;
    }
    
    public function getSportarten(){
        return $this->sportarten;
    }
    
    public function getSelectedSportart(){
        return $this->sportarten[$this->selected];
    }

}
